package com.black.product.controller;

import com.black.product.service.ProductService;
import com.black.product.bean.Product;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * @Author: Young
 * @CreateTime: 2025-07-28
 * @Description:
 * @Version: 1.0
 */
@RestController
public class ProductController {

    @Autowired
    private ProductService productService;

    @GetMapping("/product/{id}")
    public Product getProduct(@PathVariable("id") Long id,
                              HttpServletRequest request) {
        String xToken = request.getHeader("X-Token");
        System.out.println("xToken = " + xToken);
//        try {
//            TimeUnit.SECONDS.sleep(3);
//        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
//        }
        return productService.selectById(id);
    }
}
